package com.webservice;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import javax.inject.Named;

/**
 *
 * @author Krzysztof
 */
@Named("carType")
public enum carTypes {

    Van("Van", "Dostawczy"),
    Trailer("Trailer", "Przyczepa"),
    Motorcycle("Motorcycle", "Motocykl"),
    Personal("Personal", "Osobowy");
    private String type;

    public String getType() {
        return type;
    }
    private String label;

    public String getLabel() {
        return label;
    }

    carTypes(String type, String label) {
        this.type = type;
        this.label = label;
    }

    public List<carTypes> getAll() {
        return new ArrayList<carTypes>(Arrays.asList(carTypes.values()));
    }

    public List<String> getAllLabels() {
        List<String> result = new ArrayList<String>();
        for (carTypes ct : getAll()) {
            result.add(ct.getLabel());

        }
        return result;
    }

    public List<String> getAllOptions() {
        List<String> result = new ArrayList<String>();
        for (carTypes ct : getAll()) {
            result.add(ct.getType());

        }
        return result;
    }

    public String fromLabelToValue(String s) {
        String result = "";
        for (carTypes ct : getAll()) {
            if (ct.label.equals(s)) {
                result = ct.getType();
            }
        }
         return result;
    }
    public String fromValueToLabel(String s) {
        String result = "";
        for (carTypes ct : getAll()) {
            if (ct.type.equals(s)) {
                result = ct.getLabel();
            }
        }
         return result;
    }
}